class MyStack {
public:
    MyStack()
    {}
    
    void push(int x) 
    {
        while(!tmp2.empty())
        {
            int num=tmp2.front();
            tmp2.pop();
            tmp1.push(num);
        }
        tmp2.push(x);
        while(!tmp1.empty())
        {
            int num=tmp1.front();
            tmp1.pop();
            tmp2.push(num);
        }

    }
    
    int pop() 
    {
        int num=tmp2.front();
        tmp2.pop();
        return num;
    }
    
    int top() 
    {
        return tmp2.front();

    }
    
    bool empty() 
    {
        return tmp2.empty();

    }
private:
    queue<int> tmp1;    //暂存
    queue<int> tmp2;    //真正
};

/**
 * Your MyStack object will be instantiated and called as such:
 * MyStack* obj = new MyStack();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->top();
 * bool param_4 = obj->empty();
 */
